package com.tencent.iov.cowin.befsale.clue.controller.clue;

import com.tencent.iov.cowin.befsale.clue.controller.clue.assembler.ClueDayStatsAssembler;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.AddClueDayStatsRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.DeleteClueDayStatsRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.QueryClueDayStatsRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.UpdateClueDayStatsRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.response.ClueDayStatsResponse;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.ClueIntentionGradeDataRequest;
import com.tencent.iov.cowin.befsale.clue.domain.clue.po.ClueDayStats;
import com.tencent.iov.cowin.befsale.clue.service.clue.ClueDayStatsService;
import com.software.boot.common.entity.Response;
import com.software.boot.common.model.dao.PageRequest;
import com.software.boot.common.model.dao.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Describe: 线索统计看板表_Controller层
 * @author: zly
 * @created: 2022-01-14 09:42:56
 * @version: 1.0
 */
@RestController
@RequestMapping(value = "/v1/clueDayStats", produces = MediaType.APPLICATION_JSON_VALUE)
@Api(tags = "线索统计看板表_Controller层")
public class ClueDayStatsController {

    @Autowired
    private ClueDayStatsService clueDayStatsService;

    /**
     * 通过ID获取详细信息
     *
     * @param: id
     * @return: ClueDayStats对象
     */
    @ApiOperation(value = "ClueDayStats管理-通过ID获取详细信息接口", httpMethod = "GET", response = Response.class, notes = "get_detail_by_id")
    @RequestMapping(path = "/get_detail_by_id", method = RequestMethod.GET)
    public Response<ClueDayStatsResponse> getDetailById(@ApiParam(required = true, value = "对象ID", defaultValue = "1") @RequestParam("id") Long id) {
        return Response.success(ClueDayStatsAssembler.transformPOToResponseVo(clueDayStatsService.getDetailById(id), ClueDayStatsResponse.class));
    }

    /**
     * 单条数据插入ClueDayStats
     *
     * @param request
     * @return 插入的条数
     */
    @ApiOperation(value = "ClueDayStats管理-添加信息接口", httpMethod = "POST", response = Response.class, notes = "add")
    @RequestMapping(path = "/add", method = RequestMethod.POST)
    public Response<Integer> add(@Valid @RequestBody AddClueDayStatsRequest request) {
        return Response.success(clueDayStatsService.insert(ClueDayStatsAssembler.transformVOToPO(request, ClueDayStats.class)));
    }

    /**
     * 批量插入ClueDayStats
     *
     * @param requests
     * @return 批量插入的条数
     */
    @ApiOperation(value = "ClueDayStats管理-批量插入ClueDayStats接口", httpMethod = "POST", response = Response.class, notes = "add_batch")
    @RequestMapping(path = "/add_batch", method = RequestMethod.POST)
    public Response<Integer> addBatch(@Valid @RequestBody List<QueryClueDayStatsRequest> requests) {
        return Response.success(clueDayStatsService.insertBatch(ClueDayStatsAssembler.transformPOToResponseVoList(requests, ClueDayStats.class)));
    }

    /**
     * 通过ID修改信息接口
     *
     * @param: request
     * @return: 修改的条数
     */
    @ApiOperation(value = "ClueDayStats管理-修改信息接口", httpMethod = "POST", response = Response.class, notes = "update")
    @RequestMapping(path = "/update", method = RequestMethod.POST)
    public Response<Integer> update(@Valid @RequestBody UpdateClueDayStatsRequest request) {
        return Response.success(clueDayStatsService.update(ClueDayStatsAssembler.transformVOToPO(request, ClueDayStats.class)));
    }

    /**
     * 通过ID删除数据
     *
     * @param request
     * @return 删除的条数
     */
    @ApiOperation(value = "ClueDayStats管理-通过ID删除接口", httpMethod = "POST", response = Response.class, notes = "delete")
    @RequestMapping(path = "/delete", method = RequestMethod.POST)
    public Response<Integer> delete(@Valid @RequestBody DeleteClueDayStatsRequest request) {
        return Response.success(clueDayStatsService.delete(ClueDayStatsAssembler.transformVOToPO(request, ClueDayStats.class)));
    }

    /**
     * 根据条件查询对象list列表
     *
     * @param request
     * @return 查询结果
     */
    @ApiOperation(value = "ClueDayStats管理-根据条件查询对象list列表接口", httpMethod = "POST", response = Response.class, notes = "query_list_by_param")
    @RequestMapping(path = "/get_list_by_param", method = RequestMethod.POST)
    public Response<List<ClueDayStatsResponse>> getListByParam(@RequestBody QueryClueDayStatsRequest request) {
        List<ClueDayStats> responseList = clueDayStatsService.getListByParam(ClueDayStatsAssembler.transformVOToPO(request, ClueDayStats.class));
        return Response.success(ClueDayStatsAssembler.transformPOToResponseVoList(responseList, ClueDayStatsResponse.class));
    }

    /**
     * 根据条件查询对象Page记录
     *
     * @param request
     * @return 查询结果
     */
    @ApiOperation(value = "ClueDayStats管理-根据条件查询对象Page记录接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
    @RequestMapping(value = "/get_page_by_param", method = RequestMethod.POST)
    public Response<PageResponse<ClueDayStatsResponse>> getPageByParam(@RequestBody PageRequest<QueryClueDayStatsRequest> request) {
        PageResponse<ClueDayStats> clueDayStatsPageResponse = clueDayStatsService.getPageByParam(ClueDayStatsAssembler.transformVOToPOPage(request, ClueDayStats.class));
        return Response.success(ClueDayStatsAssembler.transformPOToResponseVoPage(clueDayStatsPageResponse, ClueDayStatsResponse.class));
    }

    /**
     * 根据条件查询单个对象
     *
     * @param request
     * @return 查询结果
     */
    @ApiOperation(value = "ClueDayStats管理-根据条件查询单个对象接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
    @RequestMapping(value = "/get_one_by_param", method = RequestMethod.POST)
    public Response<ClueDayStatsResponse> getOneByParam(@RequestBody QueryClueDayStatsRequest request) {
        ClueDayStats clueDayStats = clueDayStatsService.getOneByParam(ClueDayStatsAssembler.transformVOToPO(request, ClueDayStats.class));
        return Response.success(ClueDayStatsAssembler.transformPOToResponseVo(clueDayStats, ClueDayStatsResponse.class));
    }

    /**
     * 管理看板-顾问排行
     * add by zly 2022-01-14
     * @param clueDataRequest
     * @return
     */
    @ApiOperation(value = "管理看板-顾问排行", httpMethod = "POST", response = Response.class, notes = "getClueTaskDataByType")
    @RequestMapping(value = "/getClueTaskDataByType", method = RequestMethod.POST)
    public Response<PageResponse<ClueDayStatsResponse>> getClueTaskDataByType(@RequestBody PageRequest<ClueIntentionGradeDataRequest> clueDataRequest){
        PageResponse<ClueDayStats> clueDayStatsPageResponse = clueDayStatsService.getClueTaskDataByType(clueDataRequest);
        return Response.success(ClueDayStatsAssembler.transformPOToResponseVoPage(clueDayStatsPageResponse, ClueDayStatsResponse.class));
    }


    /**
     * 定时器执行-同步数据入库-同步线索管理统计数据入库
     * add by zly 2022-01-14
     * @return
     */
    @ApiOperation(value = "管理看板-批量新增或者修改统计线索数据信息", httpMethod = "GET", response = Response.class, notes = "syncInsertOrUpdateBatch")
    @RequestMapping(value = "/syncInsertOrUpdateBatch", method = RequestMethod.GET)
    public Response<Boolean> syncInsertOrUpdateBatch(@ApiParam(required = false, value = "统计日期,指定到天：yyyy-mm-dd") @RequestParam("sysnTime") String sysnTime){
        Boolean falg = clueDayStatsService.syncInsertOrUpdateBatch(sysnTime);
        return Response.success(falg);
    }

    /**
     * 定时器执行-同步数据入库-同步对接企微统计数据入库
     * add by zly 2022-01-16
     * @return
     */
    @ApiOperation(value = "管理看板-批量修改统计企微信息入库", httpMethod = "GET", response = Response.class, notes = "syncUpdateBatchWithQwData")
    @RequestMapping(value = "/syncUpdateBatchWithQwData", method = RequestMethod.GET)
    public Response<Boolean> syncUpdateBatchWithQwData(@ApiParam(required = false, value = "统计日期,指定到天：yyyy-mm-dd") @RequestParam("sysnTime") String sysnTime){
        Boolean falg = clueDayStatsService.syncUpdateBatchWithQwData(sysnTime);
        return Response.success(falg);
    }

}